//
//  Mine_WalletViewController.m
//  fxxiaoke
//
//  Created by 鞠超 on 16/9/25.
//  Copyright © 2016年 jc. All rights reserved.
//

#import "Mine_WalletViewController.h"

#import "Common_problemViewController.h"
#import "IncomeDetailsViewController.h"
#import "BankCardViewController.h"
#import "RedPacketViewController.h"
#import "Wallet_RechargeViewController.h"
#import "Wallet_WithdrawViewController.h"

@interface Mine_WalletViewController () <UIScrollViewDelegate>

@property (nonatomic, strong) UIScrollView * scrollView;
//
@property (nonatomic, strong) UILabel * lbl_change;
@property (nonatomic, strong) UILabel * lbl_cardNumber;

@end

@implementation Mine_WalletViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self p_navi];
    
    [self p_setupView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navi
- (void )p_navi
{
    _btnLeft.hidden = YES;
    _lblLeft.hidden = YES;
    _btnRight.hidden = YES;
    _lblRight.hidden = YES;
    
    _lblTitle.text = @"XX钱包";
    _topView.backgroundColor = [UIColor orangeColor];
    
    //左返回
    UIImageView * image_LeftRetrun = [[UIImageView alloc] initWithFrame:CGRectMake(11, 31.5, 25, 25)];
    image_LeftRetrun.userInteractionEnabled = YES;
    image_LeftRetrun.image = [UIImage imageNamed:@"Left-return.png"];
    [_topView addSubview:image_LeftRetrun];
    
    UILabel * lbl_return = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_LeftRetrun.frame) - 6, 35, 35, 15)];
    lbl_return.text = @"返回";
    lbl_return.textColor = [UIColor whiteColor];
    lbl_return.font = [UIFont systemFontOfSize:17];
    [_topView addSubview:lbl_return];
    
    UIButton * btn_return = [UIButton buttonWithType:(UIButtonTypeSystem)];
    btn_return.frame = CGRectMake(10, 22, 60, 40);
    [_topView addSubview:btn_return];
    [btn_return addTarget:self action:@selector(btn_returnAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

//左返回
- (void )btn_returnAction:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

//显示tabbar
- (void )viewWillAppear:(BOOL)animated
{
    [(AppDelegate *)[[UIApplication sharedApplication] delegate] hiddenTabBar];
}

#pragma mark - 布局
- (void )p_setupView
{
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64)];
    self.scrollView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.scrollView.showsVerticalScrollIndicator = NO;
    self.scrollView.contentSize = CGSizeMake(0, 0);
    self.scrollView.delegate = self;
    [self.view addSubview:self.scrollView];
    
    //头视图
    [self p_headView];
    
    //剩余视图
    [self p_otherView];
}

#pragma mark - 点击进入我的红包
- (void )btn_redPacketAction:(UIButton *)sender
{//NSLog(@"点击进入我的红包");
    RedPacketViewController * redPacketViewController = [[RedPacketViewController alloc] init];
    [self showViewController:redPacketViewController sender:nil];
}

#pragma mark - 点击进入银行卡
- (void )btn_BankCardAction:(UIButton *)sender
{//NSLog(@"点击进入银行卡");
    BankCardViewController * bankCardViewController = [[BankCardViewController alloc] init];
    [self showViewController:bankCardViewController sender:nil];
}

#pragma mark - 点击进入收支明细
- (void )btn_incomeDetailsAction:(UIButton *)sender
{//NSLog(@"点击进入收支明细");
    IncomeDetailsViewController * incomeDetailsViewController = [[IncomeDetailsViewController alloc] init];
    [self showViewController:incomeDetailsViewController sender:nil];
}

#pragma mark - 点击常见问题
- (void )btn_questionAction:(UIButton *)sender
{//NSLog(@"点击常见问题");
    Common_problemViewController * common_problemViewController = [[Common_problemViewController alloc] init];
    [self showViewController:common_problemViewController sender:nil];
}

#pragma mark - 点击充值
- (void )btn_RechargeAction:(UIButton *)sender
{
//    NSLog(@"点击充值,跳页");
    
    Wallet_RechargeViewController * wallet_RechargeViewController = [[Wallet_RechargeViewController alloc] init];
    [self showViewController:wallet_RechargeViewController sender:nil];
}

#pragma mark - 点击提现
- (void )btn_WithdrawAction:(UIButton *)sender
{
//    NSLog(@"点击提现,跳页");
    
    Wallet_WithdrawViewController * wallet_WithdrawViewController = [[Wallet_WithdrawViewController alloc] init];
    [self showViewController:wallet_WithdrawViewController sender:nil];
}

//********************************************************
#pragma mark - 头视图
- (void )p_headView
{
    UIView * view_bg = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 190)];
    view_bg.backgroundColor = [UIColor orangeColor];
    [self.scrollView addSubview:view_bg];
    
    UILabel * lbl_place = [[UILabel alloc] initWithFrame:CGRectMake(50, 30, SCREEN_WIDTH - 100, 15)];
    lbl_place.text = @"我的零钱";
    lbl_place.font = [UIFont systemFontOfSize:16.0f];
    lbl_place.textColor = [UIColor whiteColor];
    lbl_place.textAlignment = NSTextAlignmentCenter;
    [view_bg addSubview:lbl_place];
    
    self.lbl_change = [[UILabel alloc] initWithFrame:CGRectMake(50, CGRectGetMaxY(lbl_place.frame) + 15, SCREEN_WIDTH - 100, 30)];
    self.lbl_change.text = @"￥ 0.00";
    self.lbl_change.font = [UIFont systemFontOfSize:25.0f];
    self.lbl_change.textColor = [UIColor whiteColor];
    self.lbl_change.textAlignment = NSTextAlignmentCenter;
    [view_bg addSubview:self.lbl_change];
    
    UIView * view_LineH = [[UIView alloc] initWithFrame:CGRectMake(0, 140, SCREEN_WIDTH, 1)];
    view_LineH.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [view_bg addSubview:view_LineH];
    
    UIView * view_LineV = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 2 - 0.5, 140, 1, 50)];
    view_LineV.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [view_bg addSubview:view_LineV];
    
    //充值
    UIImageView * image_Recharge = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 4 - 30, CGRectGetMaxY(view_LineH.frame) + 15, 20, 20)];
    image_Recharge.image = [UIImage imageNamed:@"Rechange.png"];
    [view_bg addSubview:image_Recharge];
    
    UILabel * lbl_Recharge = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_Recharge.frame) + 10, CGRectGetMaxY(view_LineH.frame) + 17.5, 50, 15)];
    lbl_Recharge.text = @"充值";
    lbl_Recharge.textColor = [UIColor whiteColor];
    lbl_Recharge.font = [UIFont systemFontOfSize:17.0f];
    [view_bg addSubview:lbl_Recharge];
    
    UIButton * btn_Recharge = [UIButton buttonWithType:(UIButtonTypeCustom)];
    btn_Recharge.frame = CGRectMake(0, CGRectGetMaxY(view_LineH.frame), SCREEN_WIDTH / 2, 50);
    [view_bg addSubview:btn_Recharge];
    [btn_Recharge addTarget:self action:@selector(btn_RechargeAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    //提现
    UIImageView * image_Withdraw = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH / 2 + SCREEN_WIDTH / 4 - 30, CGRectGetMaxY(view_LineH.frame) + 15, 20, 20)];
    image_Withdraw.image = [UIImage imageNamed:@"Withdraw.png"];
    [view_bg addSubview:image_Withdraw];
    
    UILabel * lbl_Withdraw = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_Withdraw.frame) + 10, CGRectGetMaxY(view_LineH.frame) + 17.5, 50, 15)];
    lbl_Withdraw.text = @"提现";
    lbl_Withdraw.textColor = [UIColor whiteColor];
    lbl_Withdraw.font = [UIFont systemFontOfSize:17.0f];
    [view_bg addSubview:lbl_Withdraw];
    
    UIButton * btn_Withdraw = [UIButton buttonWithType:(UIButtonTypeCustom)];
    btn_Withdraw.frame = CGRectMake(SCREEN_WIDTH / 2, CGRectGetMaxY(view_LineH.frame), SCREEN_WIDTH / 2, 50);
    [view_bg addSubview:btn_Withdraw];
    [btn_Withdraw addTarget:self action:@selector(btn_WithdrawAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

#pragma mark - 剩余视图
- (void )p_otherView
{
    //我的红包
    UIView * view_redPacket = [[UIView alloc] initWithFrame:CGRectMake(0, 190 + 10, SCREEN_WIDTH, 50)];
    view_redPacket.backgroundColor = [UIColor whiteColor];
    [self.scrollView addSubview:view_redPacket];
    
    UIView * line_top = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 1)];
    line_top.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [view_redPacket addSubview:line_top];
    
    UIView * line_redPacket = [[UIView alloc] initWithFrame:CGRectMake(18, 49, SCREEN_WIDTH - 18, 1)];
    line_redPacket.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [view_redPacket addSubview:line_redPacket];
    
    UIImageView * image_redPacket = [[UIImageView alloc] initWithFrame:CGRectMake(20, 12.5, 25, 25)];
    image_redPacket.image = [UIImage imageNamed:@"redpacket.png"];
    [view_redPacket addSubview:image_redPacket];
    
    UILabel * lbl_redPacket = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_redPacket.frame) + 15, 15, 100, 20)];
    lbl_redPacket.text = @"我的红包";
    lbl_redPacket.textColor = [UIColor blackColor];
    lbl_redPacket.font = [UIFont systemFontOfSize:17.0f];
    [view_redPacket addSubview:lbl_redPacket];
    
    UIImageView * return_redPacket = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 10 - 20, 15, 20, 20)];
    return_redPacket.image = [UIImage imageNamed:@"rigth-return.png"];
    [view_redPacket addSubview:return_redPacket];
    
    UIButton * btn_redPacket = [UIButton buttonWithType:(UIButtonTypeCustom)];
    btn_redPacket.frame = CGRectMake(0, 0, SCREEN_WIDTH, 50);
    [view_redPacket addSubview:btn_redPacket];
    [btn_redPacket addTarget:self action:@selector(btn_redPacketAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    //银行卡
    UIView * view_BankCard = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(view_redPacket.frame), SCREEN_WIDTH, 50)];
    view_BankCard.backgroundColor = [UIColor whiteColor];
    [self.scrollView addSubview:view_BankCard];
    
    UIView * line_BankCard = [[UIView alloc] initWithFrame:CGRectMake(18, 49, SCREEN_WIDTH - 18, 1)];
    line_BankCard.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [view_BankCard addSubview:line_BankCard];
    
    UIImageView * image_BankCard = [[UIImageView alloc] initWithFrame:CGRectMake(20, 12.5, 25, 25)];
    image_BankCard.image = [UIImage imageNamed:@"BankCard.png"];
    [view_BankCard addSubview:image_BankCard];
    
    UILabel * lbl_BankCard = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_redPacket.frame) + 15, 15, 100, 20)];
    lbl_BankCard.text = @"银行卡";
    lbl_BankCard.textColor = [UIColor blackColor];
    lbl_BankCard.font = [UIFont systemFontOfSize:17.0f];
    [view_BankCard addSubview:lbl_BankCard];
    
    UIImageView * return_BankCard = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 10 - 20, 15, 20, 20)];
    return_BankCard.image = [UIImage imageNamed:@"rigth-return.png"];
    [view_BankCard addSubview:return_BankCard];
    
    self.lbl_cardNumber = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 30 - 5 - 50, 15, 50, 20)];
    self.lbl_cardNumber.text = @"0张";
    self.lbl_cardNumber.textColor = [UIColor grayColor];
    self.lbl_cardNumber.textAlignment = NSTextAlignmentRight;
    [view_BankCard addSubview:self.lbl_cardNumber];
    
    UIButton * btn_BankCard = [UIButton buttonWithType:(UIButtonTypeCustom)];
    btn_BankCard.frame = CGRectMake(0, 0, SCREEN_WIDTH, 50);
    [view_BankCard addSubview:btn_BankCard];
    [btn_BankCard addTarget:self action:@selector(btn_BankCardAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    //收支明细
    UIView * view_incomeDetails = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(view_BankCard.frame), SCREEN_WIDTH, 50)];
    view_incomeDetails.backgroundColor = [UIColor whiteColor];
    [self.scrollView addSubview:view_incomeDetails];
    
    UIView * line_incomeDetails = [[UIView alloc] initWithFrame:CGRectMake(0, 49, SCREEN_WIDTH, 1)];
    line_incomeDetails.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [view_incomeDetails addSubview:line_incomeDetails];
    
    UIImageView * image_incomeDetails = [[UIImageView alloc] initWithFrame:CGRectMake(20, 12.5, 25, 25)];
    image_incomeDetails.image = [UIImage imageNamed:@"incomeDetails.png"];
    [view_incomeDetails addSubview:image_incomeDetails];
    
    UILabel * lbl_incomeDetails = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(image_redPacket.frame) + 15, 15, 100, 20)];
    lbl_incomeDetails.text = @"收支明细";
    lbl_incomeDetails.textColor = [UIColor blackColor];
    lbl_incomeDetails.font = [UIFont systemFontOfSize:17.0f];
    [view_incomeDetails addSubview:lbl_incomeDetails];
    
    UIImageView * return_incomeDetails = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 10 - 20, 15, 20, 20)];
    return_incomeDetails.image = [UIImage imageNamed:@"rigth-return.png"];
    [view_incomeDetails addSubview:return_incomeDetails];
    
    UIButton * btn_incomeDetails = [UIButton buttonWithType:(UIButtonTypeCustom)];
    btn_incomeDetails.frame = CGRectMake(0, 0, SCREEN_WIDTH, 50);
    [view_incomeDetails addSubview:btn_incomeDetails];
    [btn_incomeDetails addTarget:self action:@selector(btn_incomeDetailsAction:) forControlEvents:(UIControlEventTouchUpInside)];
    
    UILabel * lbl_question = [[UILabel alloc] initWithFrame:CGRectMake(50, SCREEN_HEIGHT - 74 - 20, SCREEN_WIDTH - 100, 20)];
    lbl_question.text = @"常见问题";
    lbl_question.textColor = [UIColor colorWithRed:90/255.0 green:167/255.0 blue:239/255.0 alpha:1.0];
    lbl_question.textAlignment = NSTextAlignmentCenter;
    lbl_question.font = [UIFont systemFontOfSize:15.0f];
    [self.scrollView addSubview:lbl_question];
    
    UIButton * btn_question = [UIButton buttonWithType:(UIButtonTypeCustom)];
    btn_question.frame = CGRectMake(SCREEN_WIDTH / 2 - 50, SCREEN_HEIGHT - 74 - 25, 100, 30);
    [self.scrollView addSubview:btn_question];
    [btn_question addTarget:self action:@selector(btn_questionAction:) forControlEvents:(UIControlEventTouchUpInside)];
}

@end
